<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();//获得项目的根目录，上下文路径
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta charset="UTF-8">
<title>shopping</title>
<script src="js/jquery.js"></script>
<script>
	$(function() {
		$("#shopNum").blur(function() {
			var v = $("#price").val();
			var v1 = $("#shopNum").val();
			var v2 = v * v1;
			$("#count").val(v2);
		});
	});
	$(function() {
		$(".submit").click(function() {
		var v = $("#remaining").val();
		var v1 = $("#shopNum").val();	
		if (v1==null||v1=="") {
			alert("购买数量不能为空！！！");
			return false;
		}
		if (v1 > v) {
			alert("剩余数量不足！！！");
			alert(v);
			alert(v1);
			return false;
		}
	});
	});
</script>
</head>
<body>
	<div align="center">
		<h2>购买商品</h2>
		<form method="get" action="Detail/updateShopping">
			<table border="1" cellpadding="0" cellspacing="0" style="width: 30%"
				align="center">
				<tr>
					<td>商品编号</td>
					<td><input type="text" name="id" value="${DETAIL.id }"
						readonly="readonly" /></td>
				</tr>
				<tr>
					<td><span>商品名称：</span></td>
					<td><input type="text" value="${DETAIL.name }"
						readonly="readonly" /></td>
				</tr>
				<tr>
					<td><span>商品分类：</span></td>
					<td><input type="text" value="${SORT.name }"
						readonly="readonly" /></td>
				</tr>
				<tr>
					<td><span>单价(元)：</span></td>
					<td><input type="text" value="${DETAIL.price }" id="price"
						readonly="readonly" /></td>
				</tr>
				<tr>
					<td><span>剩余数量：</span></td>
					<td><input type="text" name="remaining" id="remaining"
						value="${DETAIL.remaining }" readonly="readonly" /></td>
				</tr>
				<tr>
					<td><span>购买数量：</span></td>
					<td><input type="number" name="shopNum" id="shopNum" /></td>
				</tr>
				<tr>
					<td><span>总金额(元)：</span></td>
					<td><input type="text" id="count" readonly="readonly" /></td>
				</tr>
				<tr>
					<td><input type="submit" class="submit" value="购买"  /></td>
					<td><a href="Detail/getDetails">返回</a></td>
				</tr>
			</table>
		</form>
	</div>


</body>
</html>